/**
 * 
 */
package com.kandinfo.isbnmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kandinfo.base.common.dto.ResultDto;
import com.kandinfo.base.common.dto.widget.DataTablesResponseDto;
import com.kandinfo.base.common.util.AppConfigUtil;
import com.kandinfo.isbnmanage.dto.IsbnManageReqDto;
import com.kandinfo.isbnmanage.dto.IsbnManageResDto;
import com.kandinfo.isbnmanage.service.IsbnService;


/**
 * @author tangqh
 *
 */
@Controller
@RequestMapping(value = "/isbnmanage")
public class IsbnManageController {
	@Autowired
	private IsbnService isbnService;
	
	/**
	 * ISBN管理入口
	 */
    @RequestMapping(value = "/list", method=RequestMethod.GET)
    public String list(Model model){
    	model.addAttribute("title", "ISBN管理");
        return "isbnmanage/isbn_list";
    }
	/**
	 * ISBN预览
	 */
    @RequestMapping(value = "/view", method=RequestMethod.GET)
	public String view(Model model, @RequestParam String barcode) {
    	model.addAttribute("urlPrefix", AppConfigUtil.getConfig("checkAnswerImg"));
		model.addAttribute("barcode", barcode);
		return "isbnmanage/isbn_view";
	}
    /**
     * ISBN编辑
     */
    @RequestMapping(value = "/editor", method=RequestMethod.GET)
	public String editor(Model model,  String workType, String barcode,String isbnInformationId) {
		model.addAttribute("barcode", barcode);
		model.addAttribute("isbnInformationId", isbnInformationId);
		return "isbnmanage/isbn_editor";
	}
    
    @RequestMapping(value = "/getIsbnManage", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto getIsbnManage(@RequestParam Long isbnManageId){
    	return isbnService.getIsbnManage(isbnManageId);
    }
    
    @RequestMapping(value = "/getIsbnManageList", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto getIsbnManageList(@RequestBody IsbnManageReqDto isbnManageReqDto){
    	return isbnService.getIsbnManageList(isbnManageReqDto);
    }

    @RequestMapping(value = "/searchByCon", method = RequestMethod.POST)
    @ResponseBody
    public DataTablesResponseDto<IsbnManageResDto> searchByCon(@RequestBody IsbnManageReqDto isbnManageReqDto){
    	return isbnService.searchByCon(isbnManageReqDto);
    }
    
}